<?php
	define('_DOCUMENT_ROOT_', dirname(realpath(__FILE__)).'/');
	require_once(_DOCUMENT_ROOT_.'inc/config.php');
	
	class db_functions
	{
		public function __construct()
		{
			
			$this->_db    = _DB_MYSQL_NAME_;
			$this->_host  = _DB_MYSQL_HOST_;
			//$this->_dsn   = sprintf($_fmt, $this->_host, $this->_db);
			$this->_user  = _DB_MYSQL_USER_;
			$this->_pass  = _DB_MYSQL_PASS_;
			
			//$this->_table = 'city';
		}
		
		public function get_cities($country)
		{		
				try
				{
					$db = new PDO("mysql:host="._DB_MYSQL_HOST_.";dbname="._DB_MYSQL_NAME_.";charset=utf8",_DB_MYSQL_USER_,_DB_MYSQL_PASS_);
					$query = $db->prepare("Select city,name from city where country = :country");
					$query->bindParam(":country",$country);

					if(!$query->execute()) return false;
					
					$result =  $query->fetchAll(PDO::FETCH_ASSOC);
					$query->closeCursor();
					return $result;
					
				}
				catch(PDOException $e)
				{
					var_dump($e);
				}
		//return false;
		}
	}
?>